<!DOCTYPE html>

<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">

<title>module RubyXL::LegacyWorksheet - rubyXL 3.4.35</title>


  <meta name="keywords" content="ruby,module,RubyXL::LegacyWorksheet">


    <meta name="description" content="Documentation for the RubyXL::LegacyWorksheet module">





<script type="text/javascript">
  var rdoc_rel_prefix = "../";
  var index_rel_prefix = "../";
</script>

<script src="../js/navigation.js" defer></script>
<script src="../js/search.js" defer></script>
<script src="../js/search_index.js" defer></script>
<script src="../js/searcher.js" defer></script>
<script src="../js/darkfish.js" defer></script>

<link href="../css/fonts.css" rel="stylesheet">
<link href="../css/rdoc.css" rel="stylesheet">



<body id="top" role="document" class="module">
<div id="navigation-toggle" role="button" tabindex="0" aria-label="Toggle sidebar" aria-expanded="true" aria-controls="navigation">
  <span aria-hidden="true">&#9776;</span>
</div>


<nav id="navigation" role="navigation">
  <div id="project-navigation">
    <div id="home-section" role="region" title="Quick navigation" class="nav-section">
  <h2>
    <a href="../index.html" rel="home">Home</a>
  </h2>

  <div id="table-of-contents-navigation">
    <a href="../table_of_contents.html#pages">Pages</a>
    <a href="../table_of_contents.html#classes">Classes</a>
    <a href="../table_of_contents.html#methods">Methods</a>
  </div>
</div>

    <div id="search-section" role="search" class="project-section initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <div id="search-field-wrapper">
      <input id="search-field" role="combobox" aria-label="Search"
             aria-autocomplete="list" aria-controls="search-results"
             type="text" name="search" placeholder="Search (/) for a class, method, ..." spellcheck="false"
             title="Type to search, Up and Down to navigate, Enter to load">
    </div>

    <ul id="search-results" aria-label="Search Results"
        aria-busy="false" aria-expanded="false"
        aria-atomic="false" class="initially-hidden"></ul>
  </form>
</div>

  </div>

  

  

  

  
<div id="includes-section" class="nav-section">
  <h3>Included Modules</h3>

  <ul class="link-list">


    <li><span class="include">Enumerable</span></li>


  </ul>
</div>


  

  
  <div class="nav-section">
    <h3>Class Methods</h3>
    <ul class="link-list" role="directory">

      <li class="calls-super" ><a href="#method-c-new">new</a></li>

    </ul>
  </div>



  <div class="nav-section">
    <h3>Instance Methods</h3>
    <ul class="link-list" role="directory">

      <li ><a href="#method-i-5B-5D">[]</a></li>

      <li ><a href="#method-i-add_cell">add_cell</a></li>

      <li ><a href="#method-i-add_row">add_row</a></li>

      <li ><a href="#method-i-each">each</a></li>

    </ul>
  </div>



  <footer id="validator-badges" role="contentinfo">
  <p><a href="https://validator.w3.org/check/referer">Validate</a></p>
  <p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.15.1.</p>
  <p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.</p>
</footer>

</nav>

<main role="main" aria-labelledby="module-RubyXL::LegacyWorksheet">
  
  
    <ol role="navigation" aria-label="Breadcrumb navigation" class="breadcrumb">
      
      <li>
        
        <a href="../RubyXL.html">RubyXL</a><span>::</span>
        
      </li>
      
      <li>
        
        <span>LegacyWorksheet</span>
        
      </li>
      
    </ol>
  

  <h1 id="module-RubyXL::LegacyWorksheet" class="anchor-link module">
    module RubyXL::LegacyWorksheet
  </h1>

  <section class="description">
    
  </section>


  <section id="5Buntitled-5D" class="documentation-section anchor-link">





    <section class="constants-list">
      <header>
        <h3>Constants</h3>
      </header>
      <dl>

        <dt id="TEXT_LENGTH_LIMIT_IN_CELL">TEXT_LENGTH_LIMIT_IN_CELL</dt>

        <dd>

          
        </dd>


      </dl>
    </section>





     <section id="public-class-5Buntitled-5D-method-details" class="method-section anchor-link">
       <header>
         <h3>Public Class Methods</h3>
       </header>


      <div id="method-c-new" class="method-detail anchor-link ">
        <div class="method-header">

            <div class="method-heading">
              <a href="#method-c-new" title="Link to this method">
                <span class="method-name">new</span>
                <span class="method-args">(params = {})</span>
              </a>
            </div>

        </div>


          <div class="method-controls">
            <details class="method-source-toggle">
              <summary>Source</summary>
            </details>
          </div>



        <div class="method-description">

          <div class="method-source-code" id="new-source">
            <pre><span class="ruby-comment"># File lib/rubyXL/worksheet.rb, line 7</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">initialize</span>(<span class="ruby-identifier">params</span> = {})
  <span class="ruby-keyword">super</span>
  <span class="ruby-keyword">self</span>.<span class="ruby-identifier">workbook</span>   = <span class="ruby-identifier">params</span>[<span class="ruby-value">:workbook</span>]
  <span class="ruby-keyword">self</span>.<span class="ruby-identifier">sheet_name</span> = <span class="ruby-identifier">params</span>[<span class="ruby-value">:sheet_name</span>]
  <span class="ruby-keyword">self</span>.<span class="ruby-identifier">sheet_id</span>   = <span class="ruby-identifier">params</span>[<span class="ruby-value">:sheet_id</span>]
  <span class="ruby-keyword">self</span>.<span class="ruby-identifier">sheet_data</span> = <span class="ruby-constant">RubyXL</span><span class="ruby-operator">::</span><span class="ruby-constant">SheetData</span>.<span class="ruby-identifier">new</span>
  <span class="ruby-keyword">self</span>.<span class="ruby-identifier">cols</span> = <span class="ruby-constant">RubyXL</span><span class="ruby-operator">::</span><span class="ruby-constant">ColumnRanges</span>.<span class="ruby-identifier">new</span>
  <span class="ruby-ivar">@comments</span> = [] <span class="ruby-comment"># Do not optimize! These are arrays, so they will share the pointer!</span>
  <span class="ruby-ivar">@printer_settings</span> = []
  <span class="ruby-ivar">@generic_storage</span> = []
<span class="ruby-keyword">end</span></pre>
          </div>



          


            <div class="method-calls-super">
              Calls superclass method
              
            </div>

        </div>





      </div>


    </section>

     <section id="public-instance-5Buntitled-5D-method-details" class="method-section anchor-link">
       <header>
         <h3>Public Instance Methods</h3>
       </header>


      <div id="method-i-5B-5D" class="method-detail anchor-link ">
        <div class="method-header">

            <div class="method-heading">
              <a href="#method-i-5B-5D" title="Link to this method">
                <span class="method-name">[]</span>
                <span class="method-args">(row = 0)</span>
              </a>
            </div>

        </div>


          <div class="method-controls">
            <details class="method-source-toggle">
              <summary>Source</summary>
            </details>
          </div>



        <div class="method-description">

          <div class="method-source-code" id="5B-5D-source">
            <pre><span class="ruby-comment"># File lib/rubyXL/worksheet.rb, line 20</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">[]</span>(<span class="ruby-identifier">row</span> = <span class="ruby-value">0</span>)
  <span class="ruby-identifier">sheet_data</span>[<span class="ruby-identifier">row</span>]
<span class="ruby-keyword">end</span></pre>
          </div>



          <p>allows for easier access to <a href="../lib/rubyXL/objects/sheet_data_rb.html">sheet_data</a></p>


        </div>





      </div>


      <div id="method-i-add_cell" class="method-detail anchor-link ">
        <div class="method-header">

            <div class="method-heading">
              <a href="#method-i-add_cell" title="Link to this method">
                <span class="method-name">add_cell</span>
                <span class="method-args">(row_index = 0, column_index = 0, data = &#39;&#39;, formula = nil, overwrite = true)</span>
              </a>
            </div>

        </div>


          <div class="method-controls">
            <details class="method-source-toggle">
              <summary>Source</summary>
            </details>
          </div>



        <div class="method-description">

          <div class="method-source-code" id="add_cell-source">
            <pre><span class="ruby-comment"># File lib/rubyXL/worksheet.rb, line 34</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">add_cell</span>(<span class="ruby-identifier">row_index</span> = <span class="ruby-value">0</span>, <span class="ruby-identifier">column_index</span> = <span class="ruby-value">0</span>, <span class="ruby-identifier">data</span> = <span class="ruby-string">&#39;&#39;</span>, <span class="ruby-identifier">formula</span> = <span class="ruby-keyword">nil</span>, <span class="ruby-identifier">overwrite</span> = <span class="ruby-keyword">true</span>)
  <span class="ruby-identifier">validate_workbook</span>
  <span class="ruby-identifier">validate_nonnegative</span>(<span class="ruby-identifier">row_index</span>)
  <span class="ruby-identifier">validate_nonnegative</span>(<span class="ruby-identifier">column_index</span>)
  <span class="ruby-identifier">row</span> = <span class="ruby-identifier">sheet_data</span>.<span class="ruby-identifier">rows</span>[<span class="ruby-identifier">row_index</span>] <span class="ruby-operator">||</span> <span class="ruby-identifier">add_row</span>(<span class="ruby-identifier">row_index</span>)

  <span class="ruby-identifier">c</span> = <span class="ruby-identifier">row</span>.<span class="ruby-identifier">cells</span>[<span class="ruby-identifier">column_index</span>]

  <span class="ruby-keyword">if</span> <span class="ruby-identifier">overwrite</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">c</span>.<span class="ruby-identifier">nil?</span>
    <span class="ruby-identifier">c</span> = <span class="ruby-constant">RubyXL</span><span class="ruby-operator">::</span><span class="ruby-constant">Cell</span>.<span class="ruby-identifier">new</span>
    <span class="ruby-identifier">c</span>.<span class="ruby-identifier">worksheet</span> = <span class="ruby-keyword">self</span>
    <span class="ruby-identifier">c</span>.<span class="ruby-identifier">row</span> = <span class="ruby-identifier">row_index</span>
    <span class="ruby-identifier">c</span>.<span class="ruby-identifier">column</span> = <span class="ruby-identifier">column_index</span>

    <span class="ruby-keyword">if</span> <span class="ruby-identifier">formula</span> <span class="ruby-keyword">then</span>
      <span class="ruby-identifier">c</span>.<span class="ruby-identifier">formula</span> = <span class="ruby-constant">RubyXL</span><span class="ruby-operator">::</span><span class="ruby-constant">Formula</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">:expression</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-identifier">formula</span>)
      <span class="ruby-identifier">c</span>.<span class="ruby-identifier">raw_value</span> = <span class="ruby-identifier">data</span>
    <span class="ruby-keyword">else</span>
      <span class="ruby-keyword">case</span> <span class="ruby-identifier">data</span>
      <span class="ruby-keyword">when</span> <span class="ruby-constant">Numeric</span>          <span class="ruby-keyword">then</span> <span class="ruby-identifier">c</span>.<span class="ruby-identifier">raw_value</span> = <span class="ruby-identifier">data</span>
      <span class="ruby-keyword">when</span> <span class="ruby-constant">String</span>           <span class="ruby-keyword">then</span>
        <span class="ruby-keyword">if</span> <span class="ruby-identifier">data</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">&gt;</span> <span class="ruby-constant">TEXT_LENGTH_LIMIT_IN_CELL</span>
          <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-node">&quot;The maximum length of cell contents (text) is #{TEXT_LENGTH_LIMIT_IN_CELL} characters&quot;</span>
        <span class="ruby-keyword">end</span>
        <span class="ruby-identifier">c</span>.<span class="ruby-identifier">raw_value</span> = <span class="ruby-identifier">data</span>
        <span class="ruby-identifier">c</span>.<span class="ruby-identifier">datatype</span> = <span class="ruby-constant">RubyXL</span><span class="ruby-operator">::</span><span class="ruby-constant">DataType</span><span class="ruby-operator">::</span><span class="ruby-constant">RAW_STRING</span>
      <span class="ruby-keyword">when</span> <span class="ruby-constant">RubyXL</span><span class="ruby-operator">::</span><span class="ruby-constant">RichText</span> <span class="ruby-keyword">then</span>
        <span class="ruby-keyword">if</span> <span class="ruby-identifier">data</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">&gt;</span> <span class="ruby-constant">TEXT_LENGTH_LIMIT_IN_CELL</span>
          <span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>, <span class="ruby-node">&quot;The maximum length of cell contents (text) is #{TEXT_LENGTH_LIMIT_IN_CELL} characters&quot;</span>
        <span class="ruby-keyword">end</span>
        <span class="ruby-identifier">c</span>.<span class="ruby-identifier">is</span> = <span class="ruby-identifier">data</span>
        <span class="ruby-identifier">c</span>.<span class="ruby-identifier">datatype</span> = <span class="ruby-constant">RubyXL</span><span class="ruby-operator">::</span><span class="ruby-constant">DataType</span><span class="ruby-operator">::</span><span class="ruby-constant">INLINE_STRING</span>
      <span class="ruby-keyword">when</span> <span class="ruby-constant">Time</span>, <span class="ruby-constant">Date</span>, <span class="ruby-constant">DateTime</span> <span class="ruby-keyword">then</span>
        <span class="ruby-identifier">c</span>.<span class="ruby-identifier">raw_value</span> = <span class="ruby-identifier">workbook</span>.<span class="ruby-identifier">date_to_num</span>(<span class="ruby-identifier">data</span>)
      <span class="ruby-keyword">when</span> <span class="ruby-constant">NilClass</span> <span class="ruby-keyword">then</span> <span class="ruby-keyword">nil</span>
      <span class="ruby-keyword">end</span>
    <span class="ruby-keyword">end</span>

    <span class="ruby-identifier">range</span> = <span class="ruby-identifier">cols</span>&amp;.<span class="ruby-identifier">locate_range</span>(<span class="ruby-identifier">column_index</span>)
    <span class="ruby-identifier">c</span>.<span class="ruby-identifier">style_index</span> = <span class="ruby-identifier">row</span>.<span class="ruby-identifier">style_index</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">range</span>&amp;.<span class="ruby-identifier">style_index</span> <span class="ruby-operator">||</span> <span class="ruby-value">0</span>
    <span class="ruby-identifier">row</span>.<span class="ruby-identifier">cells</span>[<span class="ruby-identifier">column_index</span>] = <span class="ruby-identifier">c</span>
  <span class="ruby-keyword">end</span>

  <span class="ruby-identifier">c</span>
<span class="ruby-keyword">end</span></pre>
          </div>



          


        </div>





      </div>


      <div id="method-i-add_row" class="method-detail anchor-link ">
        <div class="method-header">

            <div class="method-heading">
              <a href="#method-i-add_row" title="Link to this method">
                <span class="method-name">add_row</span>
                <span class="method-args">(row_index = 0, params = {})</span>
              </a>
            </div>

        </div>


          <div class="method-controls">
            <details class="method-source-toggle">
              <summary>Source</summary>
            </details>
          </div>



        <div class="method-description">

          <div class="method-source-code" id="add_row-source">
            <pre><span class="ruby-comment"># File lib/rubyXL/worksheet.rb, line 28</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">add_row</span>(<span class="ruby-identifier">row_index</span> = <span class="ruby-value">0</span>, <span class="ruby-identifier">params</span> = {})
  <span class="ruby-identifier">new_row</span> = <span class="ruby-constant">RubyXL</span><span class="ruby-operator">::</span><span class="ruby-constant">Row</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">params</span>)
  <span class="ruby-identifier">new_row</span>.<span class="ruby-identifier">worksheet</span> = <span class="ruby-keyword">self</span>
  <span class="ruby-identifier">sheet_data</span>.<span class="ruby-identifier">rows</span>[<span class="ruby-identifier">row_index</span>] = <span class="ruby-identifier">new_row</span>
<span class="ruby-keyword">end</span></pre>
          </div>



          


        </div>





      </div>


      <div id="method-i-each" class="method-detail anchor-link ">
        <div class="method-header">

            <div class="method-heading">
              <a href="#method-i-each" title="Link to this method">
                <span class="method-name">each</span>
                <span class="method-args">() { |row| ... }</span>
              </a>
            </div>

        </div>


          <div class="method-controls">
            <details class="method-source-toggle">
              <summary>Source</summary>
            </details>
          </div>



        <div class="method-description">

          <div class="method-source-code" id="each-source">
            <pre><span class="ruby-comment"># File lib/rubyXL/worksheet.rb, line 24</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">each</span>
  <span class="ruby-identifier">sheet_data</span>.<span class="ruby-identifier">rows</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">row</span><span class="ruby-operator">|</span> <span class="ruby-keyword">yield</span>(<span class="ruby-identifier">row</span>) }
<span class="ruby-keyword">end</span></pre>
          </div>



          


        </div>





      </div>


    </section>

  </section>

</main>
</body>

